package com.fhj.utils;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.text.TextUtils;
import android.util.Log;

import com.fhj.movie.entity.BannerList;
import com.fhj.movie.entity.FilmEntity;
import com.fhj.movie.entity.HotList;
import com.fhj.movie.entity.HotListEntity;
import com.fhj.movie.entity.HuoDongList;
import com.fhj.movie.entity.HyyGuanShangZhiNanEntity;
import com.fhj.movie.entity.HyyTeJiaHuoDongEntity;
import com.fhj.movie.entity.JyjCinemaCircleRelListEntity;
import com.fhj.movie.entity.JyjCinemaDetailsEntity;
import com.fhj.movie.entity.JyjCinemaDistrictRelListEntity;
import com.fhj.movie.entity.JyjCinemaEntity;
import com.fhj.movie.entity.JyjCinemaSubwayRelListEntity;
import com.fhj.movie.entity.JyjCircleListEntity;
import com.fhj.movie.entity.JyjCityAllInfoEntity;
import com.fhj.movie.entity.JyjCouponListEntity;
import com.fhj.movie.entity.JyjDetailListEntity;
import com.fhj.movie.entity.JyjDistrictEntity;
import com.fhj.movie.entity.JyjMovieListEntity;
import com.fhj.movie.entity.JyjStationListEntity;
import com.fhj.movie.entity.JyjSubwayListEntity;
import com.fhj.movie.entity.JyjTicketListEntity;
import com.fhj.movie.entity.JyjTicketUnitListEntity;
import com.fhj.movie.entity.RecListEntity;
import com.fhj.movie.entity.Stills;

public class JsonUtils {

	private static JsonUtils jsonUtils;
	public static JyjCinemaDetailsEntity cinemaDetails;

	public static JyjCityAllInfoEntity   cityAllInfoEntity;
	private JsonUtils(){}
	public static JsonUtils getInstance()	{
		if (jsonUtils==null) {
			jsonUtils=new JsonUtils();
}
		return jsonUtils;
	}

	public static FilmEntity parseFilmDetail(JSONObject object){
		FilmEntity film = new FilmEntity();
		if(object!=null)
		{
			try {
				JSONObject itemObj = object.getJSONObject("object");
				film.setId(Integer.parseInt(itemObj.getString("id")));
				film.setName(itemObj.getString("name"));
				film.setHighLight(itemObj.getString("highlight"));
				film.setGrade(Double.parseDouble(itemObj.optString("grade")));
				film.setLogo(itemObj.getString("logo"));
				film.setIsNew(Integer.parseInt(itemObj.getString("isNew")));
				film.setIsSale(Integer.parseInt(itemObj.getString("isSale")));
				film.setIsDiscount(Integer.parseInt(itemObj.getString("isDiscount")));
				film.setDimensional(itemObj.getString("dimensional"));
				film.setIsSeatOccupy(Integer.parseInt(itemObj.getString("isSeatOccupy")));
				film.setReleaseDate(itemObj.getString("description"));
				film.setDescription(itemObj.optString("description"));
				film.setDuration(itemObj.getString("duration"));
				film.setDirector(itemObj.getString("director"));
				film.setActors(itemObj.getString("actors"));
				film.setLogo1(itemObj.getString("logo1"));
				film.setLogo2(itemObj.getString("logo2"));
				film.setLogo3(itemObj.getString("logo3"));
				film.setLogo556640(itemObj.getString("logo556640"));
				film.setCategory(itemObj.getString("category"));
				film.setAreaString(itemObj.getString("area"));
				film.setLanguage(itemObj.optString("language"));
				film.setIsHot(Integer.parseInt(itemObj.getString("isHot")));
				film.setPreview(itemObj.optString("preview"));
				//film.setTimeList(itemObj.optString("timeList"));
				film.setNotifyCount(Integer.parseInt(itemObj.getString("notifyCount")));
				film.setOnShowStatus(Integer.parseInt(itemObj.getString("onShowStatus")));
				//String lowPriceString = itemObj.optString("lowPrice");
				//if(lowPriceString!=null&&lowPriceString.length()!=0){
				//     film.setLowPrice(Double.parseDouble(lowPriceString));
				//}
				//film.setHighBoxOffice(Integer.parseInt(itemObj.optString("highBoxOffice")));
				//film.setStillsList(itemObj.optString("stillsList"));
				List<Stills> stills = new LinkedList<Stills>();
				JSONArray array = itemObj.getJSONArray("stillsList");
				for(int i=0;i<array.length();i++)
				{
					JSONObject stillObj = array.getJSONObject(i);
					Stills still = new Stills();
					still.setLogo(stillObj.getString("logo"));
					still.setLogo1(stillObj.getString("logo1"));
					stills.add(still);
				}
				film.setStillsList(stills);
				film.setMobilePreview(itemObj.optString("mobilePreview"));
				film.setAvailableIncurrentCity(Boolean.parseBoolean("isAvailableInCurrentCity"));
				film.setIsScheduleSupport(Integer.parseInt(itemObj.optString("isScheduleSupport")));
				film.setScreenings(itemObj.getString("screenings"));
				film.setSpell(itemObj.getString("spell"));
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
		return film;
	}

	/**
	 * json解析电影列表
	 * 
	 * @param object
	 * @return
	 */
	public static LinkedList<FilmEntity> parseFilms(JSONObject object) {
		LinkedList<FilmEntity> list = new LinkedList<FilmEntity>();
		if (object != null) {
			try {
				JSONArray array = object.getJSONArray("list");
				for (int index = 0; index < array.length(); index++) {
					JSONObject itemObj = array.getJSONObject(index);
					FilmEntity film = new FilmEntity();
					film.setId(Integer.parseInt(itemObj.getString("id")));
					film.setName(itemObj.getString("name"));
					film.setHighLight(itemObj.getString("highlight"));
					film.setGrade(Double.parseDouble(itemObj.optString("grade")));
					film.setLogo(itemObj.getString("logo"));
					film.setIsNew(Integer.parseInt(itemObj.getString("isNew")));
					film.setIsSale(Integer.parseInt(itemObj.getString("isSale")));
					film.setIsDiscount(Integer.parseInt(itemObj
							.getString("isDiscount")));
					film.setDimensional(itemObj.getString("dimensional"));
					film.setIsSeatOccupy(Integer.parseInt(itemObj
							.getString("isSeatOccupy")));
					film.setReleaseDate(itemObj.getString("description"));
					film.setDescription(itemObj.optString("description"));
					film.setDuration(itemObj.getString("duration"));
					film.setDirector(itemObj.getString("director"));
					film.setActors(itemObj.getString("actors"));
					film.setLogo1(itemObj.getString("logo1"));
					film.setLogo2(itemObj.getString("logo2"));
					film.setLogo3(itemObj.getString("logo3"));
					film.setLogo556640(itemObj.getString("logo556640"));
					film.setCategory(itemObj.getString("category"));
					film.setAreaString(itemObj.getString("area"));
					film.setLanguage(itemObj.optString("language"));
					film.setIsHot(Integer.parseInt(itemObj.getString("isHot")));
					film.setPreview(itemObj.optString("preview"));
					// film.setTimeList(itemObj.optString("timeList"));
					film.setNotifyCount(Integer.parseInt(itemObj
							.getString("notifyCount")));
					film.setOnShowStatus(Integer.parseInt(itemObj
							.getString("onShowStatus")));
					String lowPriceString = itemObj.optString("lowPrice");
					// if(lowPriceString!=null&&lowPriceString.length()!=0){
					// film.setLowPrice(Double.parseDouble(lowPriceString));
					// }
					// film.setHighBoxOffice(Integer.parseInt(itemObj.optString("highBoxOffice")));
					// film.setStillsList(itemObj.optString("stillsList"));
					film.setMobilePreview(itemObj.optString("mobilePreview"));
					film.setAvailableIncurrentCity(Boolean
							.parseBoolean("isAvailableInCurrentCity"));
					film.setIsScheduleSupport(Integer.parseInt(itemObj
							.optString("isScheduleSupport")));
					film.setScreenings(itemObj.getString("screenings"));
					film.setSpell(itemObj.getString("spell"));

					list.add(film);

				}
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return list;
	}

	/**
	 * 城市区域数据解析
	 * 
	 * @param object
	 * @return 含有城市数据的列表
	 */
	public static List<JyjDistrictEntity> parseDistrict(JSONObject object) {
		if (object != null) {
			List<JyjDistrictEntity> list = new ArrayList<JyjDistrictEntity>();
			try {
				JSONArray array = object.getJSONArray("districtList");
				for (int i = 0; i < array.length(); i++) {
					JyjDistrictEntity district = new JyjDistrictEntity();
					JSONObject obj = array.getJSONObject(i);
					district.setId(obj.optInt("id"));
					district.setName(obj.optString("name"));
					list.add(district);
				}
				return list;

			} catch (JSONException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 解析影院json数据
	 * 
	 * @param object
	 *            请求获得的影院数据
	 * @return 包含影院初始数据的一个list集合
	 */
	public static LinkedList<JyjCinemaEntity> parseCinemas(JSONObject object) {
		if (object != null) {
			LinkedList<JyjCinemaEntity> list = new LinkedList<JyjCinemaEntity>();
			try {
				JSONArray array = object.getJSONArray("cinemaList");
				for (int i = 0; i < array.length(); i++) {
					JyjCinemaEntity cinema = new JyjCinemaEntity();
					JSONObject obj = array.optJSONObject(i);
					cinema.setId(obj.optInt("id"));
					cinema.setName(obj.optString("name"));
					cinema.setDistrictId(obj.optInt("districtId"));
					cinema.setAddress(obj.optString("address"));
					cinema.setTel(obj.optString("tel"));
					cinema.setIsSeatSupport(obj.optInt("isSeatSupport"));
					cinema.setIsCouponSupport(obj.optInt("isCouponSupport"));
					cinema.setIsGroupBuySupport(obj.optInt("isGroupBuySupport"));
					cinema.setisImaxSupport(obj.optInt("isImaxSupport"));
					cinema.setMsg(obj.optString("msg"));
					cinema.setCircleName(obj.optString("circleName"));
					cinema.setCoord(obj.optString("coord"));
					cinema.setGrade(obj.optDouble("grade"));
					cinema.setSubwayLine(obj.optString("subwayLine"));
					cinema.setNewCoupon(obj.optString("newCoupon"));
					cinema.setBusline(obj.optString("busline"));
					cinema.setIsSeatOccupy(obj.optInt("isSeatOccupy"));
					cinema.setDistance(obj.optDouble("distance"));
					cinema.setLowprice(obj.optDouble("lowPrice"));
					cinema.setScreenings(obj.optString("screenings"));
					cinema.setIsDiscount(obj.optInt("isDiscount"));
					cinema.setSpell(obj.optString("spell"));
					cinema.setIsAvailableCoupon(obj.optInt("isAvailableCoupon"));
					// 未解析字段
					// "notice": null,
					// "noScheduleMsg": null,
					// "couponLimitDesc": null
					list.add(cinema);
				}
				return list;
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 影院详情Json解析
	 * 
	 * @param object
	 *            请求的json 数据
	 * @return
	 */
	public static JyjCinemaDetailsEntity parseCinemaDetails(JSONObject obj) {

		try {
			cinemaDetails = new JyjCinemaDetailsEntity();
			JSONObject object = obj.getJSONObject("cinema");
			cinemaDetails.setId(object.optInt("id"));
			cinemaDetails.setName(object.optString("name"));
			cinemaDetails.setDistrictId(object.optInt("districtId"));
			cinemaDetails.setAddress(object.optString("address"));
			cinemaDetails.setTel(object.optString("tel"));
			cinemaDetails.setIsSeatSupport(object.optInt("isSeatSupport"));
			cinemaDetails.setIsCouponSupport(object.optInt("isCouponSupport"));
			cinemaDetails.setIsGroupBuySupport(object
					.optInt("isGroupBuySupport"));
			cinemaDetails.setIsImaxSupport(object.optInt("isImaxSupport"));
			cinemaDetails.setMsg(object.optString("msg"));
			cinemaDetails.setCircleName(object.optString("circleName"));
			cinemaDetails.setCoord(object.optString("coord"));
			cinemaDetails.setGrade(object.optDouble("grade"));
			cinemaDetails.setBusline(object.optString("busline"));
			cinemaDetails.setSubwayLine(object.optString("subwayLine"));
			cinemaDetails.setNewCoupon(object.optString("newCoupon"));
			cinemaDetails.setNotice(object.optString("notice"));
			cinemaDetails.setNoScheduleMsg(object.optString("noScheduleMsg"));
			cinemaDetails.setIsSeatOccupy(object.optInt("isSeatOccupy"));
			cinemaDetails.setScreenings(object.optString("screenings"));
			cinemaDetails.setIsDiscount(object.optInt("isDiscount"));
			cinemaDetails.setSpell(object.optString("spell"));
			cinemaDetails.setIsAvailableCoupon(object
					.optInt("isAvailableCoupon"));
			JSONArray array = obj.getJSONArray("movieList");
			cinemaDetails.setMovielist(parseMovieList(array));
			array = obj.getJSONArray("couponList");
			cinemaDetails.setCouponList(parseCouponList(array));
			array = obj.getJSONArray("detailList");
			cinemaDetails.setDetailLists(parseDetailList(array));
			return cinemaDetails;
		} catch (JSONException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return null;
	}

	private static List<JyjMovieListEntity> parseMovieList(JSONArray array) {
		List<JyjMovieListEntity> movieLists = new ArrayList<JyjMovieListEntity>();
		try {
			for (int i = 0; i < array.length(); i++) {
				JyjMovieListEntity movie = new JyjMovieListEntity();
				JSONObject obj = array.getJSONObject(i);
				movie.setId(obj.optInt("id"));
				movie.setName(obj.optString("name"));
				movie.setHighlight(obj.optString("highlight"));
				movie.setGrade(obj.optDouble("grade"));
				movie.setLogo(obj.optString("logo"));
				movie.setIsNew(obj.optInt("isNew"));
				movie.setIsSale(obj.optInt("isSale"));
				movie.setIsDiscount(obj.optInt("isDiscount"));
				movie.setDimensional(obj.optString("dimensional"));
				movie.setIsSeatOccupy(obj.optInt("isSeatOccupy"));
				movie.setReleaseDate(obj.optString("releaseDate"));
				movie.setDescription(obj.optString("description"));
				movie.setDuration(obj.optString("duration"));
				movie.setDirector(obj.optString("director"));
				movie.setActors(obj.optString("actors"));
				movie.setLogo1(obj.optString("logo1"));
				movie.setLogo2(obj.optString("logo2"));
				movie.setLogo3(obj.optString("logo3"));
				movie.setLogo556640(obj.optString("logo556640"));
				movie.setCategory(obj.optString("category"));
				movie.setArea(obj.optString("area"));
				movie.setLanguage(obj.optString("language"));
				movie.setIsHOt(obj.optInt("isHot"));
				movie.setPreview(obj.optString("preview"));
				movie.setTimeList(obj.optString("timeList"));
				// notifyCount
				// movie.setonShowStatus
				// movie.setlowPrice
				// movie.sethighBoxOffice
				// movie.setstillsList
				movie.setMobilePreview(obj.optString("mobilePreview"));
				movie.setAvailableInCurrentCity(obj
						.optBoolean("isAvailableInCurrentCity"));
				movie.setIsScheduleSupport(obj.optInt("isScheduleSupport"));
				movie.setScreenings(obj.optString("screenings"));
				movie.setSpell(obj.optString("spell"));

				movieLists.add(movie);
			}
			return movieLists;

		} catch (JSONException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return null;
	}

	private static List<JyjCouponListEntity> parseCouponList(JSONArray array) {
		List<JyjCouponListEntity> list = new ArrayList<JyjCouponListEntity>();
		try {
			for (int i = 0; i < array.length(); i++) {
				JyjCouponListEntity coupon = new JyjCouponListEntity();
				JSONObject obj = array.getJSONObject(i);
				coupon.setId(obj.optInt("id"));
				coupon.setCouponName(obj.optString("couponName"));
				coupon.setCouponDesc(obj.optString("couponDesc"));
				coupon.setPrice(obj.optInt("price"));
				coupon.setCouponListPrice(obj.optInt("couponListPrice"));
				coupon.setPartnerId(obj.optInt("partnerId"));
				coupon.setPartnerName(obj.optString("partnerName"));
				coupon.setValidEndDate(obj.optInt("validEndDate"));
				coupon.setValidDays(obj.optInt("validDays"));
				coupon.setType(obj.optInt("type"));
				coupon.setAlarmStr(obj.optString("alarmStr"));
				coupon.setBuyCountLimit(obj.optBoolean("isBuyCountLimit"));
				coupon.setBuyCountMinOnce(obj.optInt("buyCountMinOnce"));
				coupon.setBuyCountMaxOnce(obj.optInt("buyCountMaxOnce"));
				list.add(coupon);
			}
			return list;
		} catch (JSONException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return null;
	}

	private static List<JyjDetailListEntity> parseDetailList(JSONArray array) {
		List<JyjDetailListEntity> list = new ArrayList<JyjDetailListEntity>();
		try {
			for (int i = 0; i < array.length(); i++) {
				JyjDetailListEntity detail = new JyjDetailListEntity();
				JSONObject obj = array.getJSONObject(i);
				detail.setDesc(obj.optString("desc"));
				detail.setType(obj.optInt("type"));
				list.add(detail);
			}
			return list;
		} catch (JSONException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return null;
	}

	public static List<JyjTicketUnitListEntity> parseFilmSchedule(
			JSONObject object) {

		if (object == null || TextUtils.isEmpty(object.toString())) {
			return null;
		}

		List<JyjTicketUnitListEntity> list = new ArrayList<JyjTicketUnitListEntity>();
		try {
			JSONArray array = object.getJSONArray("ticketUnitList");
			for (int i = 0; i < array.length(); i++) {
				JyjTicketUnitListEntity unitListEntity = new JyjTicketUnitListEntity();
				JSONObject obj = array.getJSONObject(i);
				unitListEntity.setShowDate(obj.optString("showDate"));
				unitListEntity.setType(obj.optInt("type"));
				unitListEntity.setBeforeMin(obj.optInt("beforeMin"));
				unitListEntity.setIsHaveTicket(obj.optInt("isHaveTicket"));
				unitListEntity.setTicketList(parseTicketList(obj
						.getJSONArray("ticketList")));
				list.add(unitListEntity);
			}
		} catch (JSONException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return list;
	}

	private static List<JyjTicketListEntity> parseTicketList(JSONArray array) {

		if (array == null || array.length() == 0) {
			return null;
		}

		List<JyjTicketListEntity> list = new ArrayList<JyjTicketListEntity>();

		try {
			for (int i = 0; i < array.length(); i++) {
				JyjTicketListEntity entity = new JyjTicketListEntity();
				JSONObject obj = array.getJSONObject(i);
				entity.setId(obj.optLong("id"));
				entity.setShowTime(obj.optString("showTime"));
				entity.setShowDate(obj.optString("showDate"));
				entity.setCloseTime(obj.optString("closeTime"));
				entity.setStatus(obj.optInt("status"));
				entity.setDimensional(obj.optString("dimensional"));
				entity.setLanguage(obj.optString("language"));
				entity.setListPrice(obj.optInt("listPrice"));
				entity.setPrice(obj.optDouble("price"));
				entity.setPartnerId(obj.optInt("partnerId"));
				entity.setUrl(obj.optString("url"));
				entity.setIsSellable(obj.optInt("isSellable"));
				entity.setHallSeatCount(obj.optInt("hallSeatCount"));
				entity.setEndTime(obj.optString("endTime"));
				entity.setReaminHallSeatCount(obj.optInt("remainHallSeatCount"));
				entity.setIsDiscount(obj.optInt("isDiscount"));
				entity.setIsTomorrow(obj.optInt("isTomorrow"));
				entity.setHallName(obj.optString("hallName"));
				entity.setShowStatus(obj.optInt("showStatus"));
				entity.setIsSeatOccupy(obj.optInt("isSeatOccupy"));
				entity.setUk(obj.optString("uk"));
				list.add(entity);
			}
		} catch (JSONException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return list;
	}

	/**
	 * 活动列表数据解析
	 * 
	 * @param s
	 * @return
	 */
	public static HuoDongList parseData(JSONObject s) {
		Log.i("", "---------------111->>" + s.toString());
		HuoDongList huoDongLists = new HuoDongList();
		List<BannerList> bannerLists = new ArrayList<BannerList>();
		List<HotList> hotLists = new ArrayList<HotList>();

		if (s != null) {
			try {
				JSONArray jsonArray = s.getJSONArray("bannerList");
				for (int i = 0; i < jsonArray.length(); i++) {
					JSONObject jsonObject = jsonArray.getJSONObject(i);
					BannerList banner = new BannerList();
					banner.setTitle(jsonObject.getString("title"));
					banner.setPicUrl(jsonObject.getString("picUrl"));
					banner.setClickUrl(jsonObject.getString("clickUrl"));
					bannerLists.add(banner);
				}
				JSONArray jsonArray1 = s.getJSONArray("hotList");
				Log.i("", "---------------111->>" + jsonArray1.length());
				for (int j = 0; j < jsonArray1.length(); j++) {

					JSONObject jsonObject1 = jsonArray1.getJSONObject(j);
					HotList hot = new HotList();
					hot.setPicUrl(jsonObject1.getString("picUrl"));
					hot.setClickUrl(jsonObject1.getString("clickUrl"));
					hot.setTitle(jsonObject1.getString("title"));
					hot.setActivityStatus(jsonObject1
							.getString("activityStatus"));
					hotLists.add(hot);
					Log.i("", "------------hotLists---->>" + hotLists.size());
				}

			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
		huoDongLists.setBannerLists(bannerLists);
		huoDongLists.setHotLists(hotLists);
		return huoDongLists;
	}

	/**
	 * 特价活动
	 * 
	 * @param s
	 * @return
	 */
	public static HyyTeJiaHuoDongEntity parseHuoDongData(JSONObject s) {

		HyyTeJiaHuoDongEntity entity = new HyyTeJiaHuoDongEntity();
		List<HotListEntity> hot = new ArrayList<HotListEntity>();
		List<RecListEntity> rec = new ArrayList<RecListEntity>();

		if (s != null) {
			try {
				JSONArray jsonArray = s.getJSONArray("list");
				for (int i = 0; i < jsonArray.length(); i++) {
					JSONObject object = jsonArray.getJSONObject(i);
					if (object.getInt("activityStatus") == 0
							|| object.getInt("activityStatus") == 1) {
						HotListEntity hotListEntity = new HotListEntity();
						hotListEntity.setActivityStatus(object
								.getInt("activityStatus"));
						hotListEntity.setTitle(object.getString("title"));
						hotListEntity.setClickUrl(object.getString("clickUrl"));
						hotListEntity.setPicUrl(object.getString("picUrl"));
						hot.add(hotListEntity);
					} else {
						RecListEntity recListEntity = new RecListEntity();
						recListEntity.setTitle(object.getString("title"));
						recListEntity.setClickUrl(object.getString("clickUrl"));
						recListEntity.setPicUrl(object.getString("picUrl"));
						rec.add(recListEntity);
					}

				}

			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
		entity.setHotListEntities(hot);
		entity.setRecListEntities(rec);
		return entity;

	}

	/**
	 * 观赏指南
	 * 
	 * @param s
	 * @return
	 */
	public static List<HyyGuanShangZhiNanEntity> parseGuanSHnagZhiNangData(
			JSONObject s) {

		List<HyyGuanShangZhiNanEntity> entities = new ArrayList<HyyGuanShangZhiNanEntity>();

		if (s != null) {
			try {
				JSONArray jsonArray = s.getJSONArray("list");
				for (int i = 0; i < jsonArray.length(); i++) {
					JSONObject object = jsonArray.getJSONObject(i);
					HyyGuanShangZhiNanEntity entity = new HyyGuanShangZhiNanEntity();
					entity.setTitle(object.getString("title"));
					entity.setPicUrl(object.getString("picUrl"));
					entity.setClickUrl(object.getString("clickUrl"));
					entities.add(entity);
				}

			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
		return entities;

	}


	/**
	 * 解析城市详细信息
	 * @param object   json数据
	 * @return    城市信息实体
	 */
	public static JyjCityAllInfoEntity parseCityAllInfo(JSONObject  object){
		
		 try {
			 JyjCityAllInfoEntity jyjCityAllInfoEntity = new JyjCityAllInfoEntity();
			
			 List<JyjDistrictEntity>  districtEntities = new ArrayList<JyjDistrictEntity>();
			 JSONArray districtArray = object.getJSONArray("districtList");
			 for(int i = 0;i<districtArray.length();i++){
				 JyjDistrictEntity  districtEntity = new JyjDistrictEntity();
				 JSONObject districtobject = districtArray.getJSONObject(i);
				 districtEntity.setId(districtobject.optInt("id"));
				 districtEntity.setName(districtobject.optString("name"));
				 districtEntities.add(districtEntity);
			 }
			 jyjCityAllInfoEntity.setJyjDistrictEntities(districtEntities);
			 districtEntities=null;
			 
			 List<JyjCinemaDistrictRelListEntity> cinemaDistrictRelListEntities = new ArrayList<JyjCinemaDistrictRelListEntity>();
			 JSONArray  cinemaDistrictRelArray = object.getJSONArray("cinemaDistrictRelList");
			 for(int i = 0 ;i<cinemaDistrictRelArray.length();i++){
				 JyjCinemaDistrictRelListEntity entity  = new JyjCinemaDistrictRelListEntity();
				 JSONObject obj =  cinemaDistrictRelArray.getJSONObject(i);
				 entity.setDistrictId(obj.optInt("districtId"));
				 entity.setCinemaId(obj.optInt("cinemaId"));
				 cinemaDistrictRelListEntities.add(entity);
			 }
			 jyjCityAllInfoEntity.setCinemaDistrictRelListEntities(cinemaDistrictRelListEntities);
			 cinemaDistrictRelListEntities =null;
			 
			 List<JyjCircleListEntity> circleListEntities = new ArrayList<JyjCircleListEntity>();
			 JSONArray  circleListarray = object.getJSONArray("circleList");
			 for(int i = 0; i<circleListarray.length();i++){
				 JyjCircleListEntity  entity = new JyjCircleListEntity();
				 JSONObject  obj = circleListarray.getJSONObject(i);
				 entity.setId(obj.optInt("id"));
				 entity.setName(obj.optString("name"));
				 entity.setSpell(obj.optString("spell"));	
				 entity.setDistrctId(obj.optInt("districtId"));
				 circleListEntities.add(entity);
			 }
			 jyjCityAllInfoEntity.setCircleListEntities(circleListEntities);
			 circleListEntities=null;
			 
			 List<JyjCinemaCircleRelListEntity> cinemaCircleRelListEntityes = new ArrayList<JyjCinemaCircleRelListEntity>();
			 JSONArray  cinemacircleArray = object.getJSONArray("cinemaCircleRelList");
			 for(int i=0;i<cinemacircleArray.length();i++){
				 JyjCinemaCircleRelListEntity entity  = new JyjCinemaCircleRelListEntity();
				 JSONObject  obj = cinemacircleArray.getJSONObject(i);
				 entity.setBizCircleId(obj.optInt("bizCircleId"));
				 entity.setCinemaId(obj.optInt("cinemaId"));
				 cinemaCircleRelListEntityes.add(entity);
			 }
			 jyjCityAllInfoEntity.setCinemaCircleRelListEntities(cinemaCircleRelListEntityes);
			 cinemaCircleRelListEntityes=null;
			 
			 List<JyjSubwayListEntity> subwayListEntities = new ArrayList<JyjSubwayListEntity>();
			 JSONArray  subwayArray = object.getJSONArray("subwayList");
			 for(int i = 0;i<subwayArray.length();i++){
				 JyjSubwayListEntity  entity = new JyjSubwayListEntity();
				 JSONObject  obj = subwayArray.getJSONObject(i);
				 entity.setId(obj.optInt("id"));
				 entity.setName(obj.optString("name"));
				 entity.setCityId(obj.optInt("cityId"));
				 entity.setCinemaCount(obj.optInt("cinemaCount"));
				 entity.setStationCount(obj.optInt("stationCount"));
				 entity.setGroupbuyCount(obj.optInt("groupbuyCount"));
				 entity.setWeight(obj.optInt("weight"));
				 entity.setCreateTime(obj.optLong("createTime"));
				 entity.setUpdateTime(obj.optLong("updateTime"));
				
				 JSONArray  stationArray = obj.getJSONArray("stationList");
				 List<JyjStationListEntity>  stationListEntities = new ArrayList<JyjStationListEntity>();
				 for(int j = 0;j<stationArray.length();j++){
					 JyjStationListEntity  stationEntity = new JyjStationListEntity();
					 JSONObject object2  = stationArray.getJSONObject(j);
					 stationEntity.setId(object2.optInt("id"));
					 stationEntity.setSubwayId(object2.optInt("subwayId"));
					 stationEntity.setName(object2.optString("name"));
					 stationEntity.setCinemaCount(object2.optInt("cinemaCount"));
					 stationEntity.setLatitude(object2.optDouble("latitude"));
					 stationEntity.setLongitude(object2.optDouble("longitude"));
					 stationEntity.setOrderNum(object2.optInt("orderNum"));
					 stationListEntities.add(stationEntity);
				 }
				 entity.setStationListEntities(stationListEntities);
				 subwayListEntities.add(entity);
			 }
			 jyjCityAllInfoEntity.setSubwayListEntities(subwayListEntities);
			 subwayListEntities=null;
			 
			 JSONArray  cinemaSubwayRellistArray = object.getJSONArray("cinemaSubwayRelList");
			 List<JyjCinemaSubwayRelListEntity> cinemaSubwayRelListEntities = new ArrayList<JyjCinemaSubwayRelListEntity>();
			 for(int i = 0;i<cinemacircleArray.length();i++){
				 JyjCinemaSubwayRelListEntity entity = new JyjCinemaSubwayRelListEntity();
				 JSONObject obj = cinemaSubwayRellistArray.getJSONObject(i);
				 entity.setSubwayId(obj.optInt("subwayId"));
				 entity.setStationId(obj.optInt("stationId"));
				 entity.setCinemaId(obj.optInt("cinemaId"));
				 cinemaSubwayRelListEntities.add(entity);
			 }
			 jyjCityAllInfoEntity.setCinemaSubwayRelListEntities(cinemaSubwayRelListEntities);
			 cinemaSubwayRelListEntities=null;
			 
			 cityAllInfoEntity = jyjCityAllInfoEntity;
			 jyjCityAllInfoEntity = null;
			 return cityAllInfoEntity;
			
		} catch (JSONException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		 
		
		return null;}
}
